!(function () {
  if ("undefined" == typeof window.QIHOO_MONITOR) {
    var t = ["360.cn", "so.com", "leidian.com"],
      e = (function (n, r) {
        var i;
        !(function () {
          i = !0;
          try {
            var t = location.protocol.toLowerCase();
            ("http:" != t && "https:" != t) || (i = !1);
          } catch (e) {}
        })();
        var o = document,
          a = navigator,
          u = n.screen,
          c = i ? "" : document.domain.toLowerCase(),
          s = a.userAgent.toLowerCase(),
          g = {
            trim: function (t) {
              return t.replace(/^[\s\xa0\u3000]+|[\u3000\xa0\s]+$/g, "");
            },
          },
          f = {
            on: function (t, e, n) {
              t.addEventListener
                ? t && t.addEventListener(e, n, !1)
                : t && t.attachEvent("on" + e, n);
            },
            parentNode: function (t, e, n) {
              for (n = n || 5, e = e.toUpperCase(); t && n-- > 0; ) {
                if (t.tagName === e) return t;
                t = t.parentNode;
              }
              return null;
            },
          },
          d = {
            fix: function (t) {
              if (!("target" in t)) {
                var e = t.srcElement || t.target;
                e && 3 == e.nodeType && (e = e.parentNode), (t.target = e);
              }
              return t;
            },
          },
          h = (function () {
            function t(t) {
              return null != t && null != t.constructor
                ? Object.prototype.toString.call(t).slice(8, -1)
                : "";
            }
            return {
              isArray: function (e) {
                return "Array" == t(e);
              },
              isObject: function (t) {
                return null !== t && "object" == typeof t;
              },
              mix: function (t, e, n) {
                for (var r in e) (!n && (t[r] || r in t)) || (t[r] = e[r]);
                return t;
              },
              encodeURIJson: function (t) {
                var e = [];
                for (var n in t)
                  null != t[n] &&
                    e.push(
                      encodeURIComponent(n) + "=" + encodeURIComponent(t[n])
                    );
                return e.join("&");
              },
            };
          })(),
          l = {
            get: function (t) {
              try {
                var e,
                  n = new RegExp("(^| )" + t + "=([^;]*)(;|$)");
                return (e = o.cookie.match(n)) ? unescape(e[2]) : "";
              } catch (r) {
                return "";
              }
            },
            set: function (t, e, n) {
              n = n || {};
              var r = n.expires;
              "number" == typeof r &&
                ((r = new Date()), r.setTime(r.getTime() + n.expires));
              try {
                o.cookie =
                  t +
                  "=" +
                  escape(e) +
                  (r ? ";expires=" + r.toGMTString() : "") +
                  (n.path ? ";path=" + n.path : "") +
                  (n.domain ? "; domain=" + n.domain : "");
              } catch (i) {}
            },
          },
          m = {
            getColorDepth: function () {
              return u.colorDepth + "-bit";
            },
            getLanguage: function () {
              return (a.language || a.browserLanguage).toLowerCase();
            },
            getScreenSize: function () {
              return u.width + "x" + u.height;
            },
            getProject: function () {
              return "";
            },
            getReferrer: function () {
              var t = o.referrer || "";
              return t.indexOf("pass") > -1 || t.indexOf("pwd") > -1
                ? "403"
                : t;
            },
            getBrowser: function () {
              var t = {
                "360se-ua": "360se",
                TT: "tencenttraveler",
                Maxthon: "maxthon",
                GreenBrowser: "greenbrowser",
                Sogou: "se 1.x / se 2.x",
                TheWorld: "theworld",
              };
              for (var e in t) if (s.indexOf(t[e]) > -1) return e;
              var r = !1;
              try {
                +external
                  .twGetVersion(external.twGetSecurityID(n))
                  .replace(/\./g, "") > 1013 && (r = !0);
              } catch (o) {}
              if (r) return "360se-noua";
              var i = s.match(/(msie|chrome|safari|firefox|opera|trident)/);
              return (
                (i = i ? i[0] : ""),
                "msie" == i
                  ? (i = s.match(/msie[^;]+/) + "")
                  : "trident" == i &&
                    s.replace(
                      /trident\/[0-9].*rv[ :]([0-9.]+)/gi,
                      function (t, e) {
                        i = "msie " + e;
                      }
                    ),
                i
              );
            },
            getLocation: function () {
              var t = "";
              try {
                t = location.href;
              } catch (e) {
                (t = o.createElement("a")), (t.href = ""), (t = t.href);
              }
              return (t = /\.(s?htm|php)/.test(t)
                ? t
                : t.replace(/\/$/, "") + "/");
            },
            hash: function (t) {
              var e = 0,
                n = 0,
                r = t.length - 1;
              for (r; r >= 0; r--) {
                var i = parseInt(t.charCodeAt(r), 10);
                (e = ((e << 6) & 268435455) + i + (i << 14)),
                  0 != (n = 266338304 & e) && (e ^= n >> 21);
              }
              return e;
            },
            guid: function () {
              for (
                var t = [
                    a.appName,
                    a.version,
                    a.language || a.browserLanguage,
                    a.platform,
                    a.userAgent,
                    u.width,
                    "x",
                    u.height,
                    u.colorDepth,
                    o.referrer,
                  ].join(""),
                  e = t.length,
                  r = n.history.length;
                r;

              )
                t += r-- ^ e++;
              return (
                2147483647 *
                (Math.round(2147483647 * Math.random()) ^ m.hash(t))
              );
            },
            getSid: function () {
              var t = l.get("__DC_sid");
              if (!t && (t = l.get("__sid"))) {
                4 !== t.split(".").length && (t = null);
              }
              t ||
                (t = [
                  m.hash(i ? "" : o.domain),
                  m.guid(),
                  +new Date() + Math.random(),
                ].join("."));
              var e = { expires: 60 * (m._activeTime || 30) * 1e3, path: "/" };
              return l.set("__DC_sid", t, e), t;
            },
            getMid: function () {
              try {
                return external.GetMID(external.GetSID(n));
              } catch (t) {
                return "";
              }
            },
            getGid: function () {
              var e = l.get("__DC_gid");
              if (!e && (e = l.get("__gid"))) {
                5 !== e.split(".").length && (e = null);
              }
              e
                ? ((e = e.split(".")),
                  (e[3] = new Date().getTime()),
                  (e[4] = (parseInt(e[4]) || 1) + 1),
                  (e = e.join(".")))
                : (e = [
                    m.hash(i ? "" : o.domain),
                    Math.floor(1e9 * Math.random()),
                    new Date().getTime(),
                    new Date().getTime(),
                    1,
                  ].join("."));
              var n = { expires: 63072e6, path: "/" };
              if (t.length)
                for (var r = 0; r < t.length; r++) {
                  var a = t[r],
                    u = "." + a;
                  if (
                    (c.indexOf(u) > 0 &&
                      c.lastIndexOf(u) == c.length - u.length) ||
                    c == a
                  ) {
                    n.domain = u;
                    break;
                  }
                }
              return l.set("__DC_gid", e, n), e;
            },
            getGuid: function () {
              var e = l.get("__guid");
              if (!e) {
                e = [
                  m.hash(i ? "" : o.domain),
                  m.guid(),
                  +new Date() + Math.random() + Math.random(),
                ].join(".");
                var n = { expires: 2592e7, path: "/" };
                if (t.length)
                  for (var r = 0; r < t.length; r++) {
                    var a = t[r],
                      u = "." + a;
                    if (
                      (c.indexOf(u) > 0 &&
                        c.lastIndexOf(u) == c.length - u.length) ||
                      c == a
                    ) {
                      n.domain = u;
                      break;
                    }
                  }
                l.set("__guid", e, n);
              }
              return e;
            },
            getCount: (function () {
              var t = l.get("__DC_monitor_count");
              return (
                t || (t = l.get("monitor_count")),
                (t = (parseInt(t) || 0) + 1),
                l.set("__DC_monitor_count", t, { expires: 864e5, path: "/" }),
                function () {
                  return t;
                }
              );
            })(),
            getFlashVer: function () {
              var t = -1;
              if (a.plugins && a.mimeTypes.length) {
                var e = a.plugins["Shockwave Flash"];
                e &&
                  e.description &&
                  (t =
                    e.description
                      .replace(/([a-zA-Z]|\s)+/, "")
                      .replace(/(\s)+r/, ".") + ".0");
              } else if (n.ActiveXObject && !n.opera)
                try {
                  var r = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                  if (r) {
                    var i = r.GetVariable("$version");
                    t = i.replace(/WIN/g, "").replace(/,/g, ".");
                  }
                } catch (o) {}
              return (t = parseInt(t, 10));
            },
            getContainerId: function (t) {
              var e, n;
              for (
                w.areaIds &&
                (e = new RegExp("^(" + w.areaIds.join("|") + ")$", "ig"));
                t;

              ) {
                if (
                  t.attributes &&
                  ("bk" in t.attributes || "data-bk" in t.attributes)
                ) {
                  if ((n = t.getAttribute("bk") || t.getAttribute("data-bk")))
                    return (n = "bk:" + n), n.substr(0, 100);
                  if (t.id)
                    return (
                      (n = t.getAttribute("data-desc") || t.id),
                      n.substr(0, 100)
                    );
                } else if (e && t.id && e.test(t.id))
                  return (
                    (n = t.getAttribute("data-desc") || t.id), n.substr(0, 100)
                  );
                t = t.parentNode;
              }
              return "";
            },
            getText: function (t) {
              var e = "";
              return (
                (e =
                  "input" == t.tagName.toLowerCase()
                    ? t.getAttribute("text") ||
                      t.getAttribute("data-text") ||
                      t.value ||
                      t.title ||
                      ""
                    : t.getAttribute("text") ||
                      t.getAttribute("data-text") ||
                      t.innerText ||
                      t.textContent ||
                      t.title ||
                      ""),
                g.trim(e).substr(0, 100)
              );
            },
            getHref: function (t) {
              try {
                return t.getAttribute("data-href") || t.href || "";
              } catch (e) {
                return "";
              }
            },
          },
          p = (function () {
            function t(t) {
              t && "function" == typeof t.beforeLog && n.push(t);
            }
            function e(t) {
              n.splice(n.indexOf(t), 1);
            }
            var n = [];
            return {
              addPlugin: function (n) {
                var r, i;
                if (h.isArray(n)) for (i = n.length, r = 0; r < i; r++) t(n[r]);
                else t(n);
                return function () {
                  e(n), (n = null);
                };
              },
              getExtend: function (t, e) {
                var r,
                  i = n.length,
                  o = e;
                for (r = 0; r < i; r++)
                  try {
                    o = h.mix(o, n[r].beforeLog(t, e));
                  } catch (a) {}
                return o;
              },
            };
          })(),
          v = {
            getBase: function () {
              return {
                p: m.getProject(),
                u: m.getLocation(),
                guid: m.getGuid(),
                gid: m.getGid(),
                sid: m.getSid(),
                title: document.title,
                mid: m.getMid(),
              };
            },
            getTrack: function (t) {
              var e = m.getSid() === m.getSid() ? 1 : 0,
                n = {
                  b: m.getBrowser(),
                  c: m.getCount(),
                  r: m.getReferrer(),
                  fl: m.getFlashVer(),
                  sd: m.getColorDepth(),
                  sr: m.getScreenSize(),
                  ul: m.getLanguage(),
                  ce: e,
                };
              if (t) {
                t = t.split(",");
                for (var r = [], i = 0, o = t.length; i < o; i++) {
                  var a = l.get(t[i]);
                  r.push(t[i] + "=" + encodeURIComponent(a));
                }
                n.uc = encodeURIComponent(r.join("&"));
              }
              return n;
            },
            getClick: function (t) {
              t = d.fix(t || event);
              var e = t.target,
                n = e.tagName,
                r = m.getContainerId(e);
              if (!e.type || ("submit" != e.type && "button" != e.type)) {
                if ("AREA" == n)
                  return {
                    f: m.getHref(e),
                    c: "area:" + e.parentNode.name,
                    cId: r,
                  };
                var i, o;
                return (
                  "IMG" == n && (i = e),
                  !!(e = f.parentNode(e, "A")) &&
                    ((o = m.getText(e)),
                    {
                      f: m.getHref(e),
                      c: o || (i ? i.src.match(/[^\/]+$/) : ""),
                      cId: r,
                    })
                );
              }
              var a = f.parentNode(e, "FORM"),
                u = {};
              if (a) {
                var c = a.id || "",
                  s = e.id;
                if (
                  ((u = { f: a.action, c: "form:" + (a.name || c), cId: r }),
                  !(
                    ("search-form" != c && "searchForm" != c) ||
                    ("searchBtn" != s && "search-btn" != s)
                  ))
                ) {
                  var g = b("kw") || b("search-kw") || b("kw1");
                  u.w = g ? g.value : "";
                }
              } else u = { f: m.getHref(e), c: m.getText(e), cId: r };
              return u;
            },
            getKeydown: function (t) {
              if (((t = d.fix(t || event)), 13 != t.keyCode)) return !1;
              var e = t.target,
                n = e.tagName,
                r = m.getContainerId(e);
              if ("INPUT" == n) {
                var i = f.parentNode(e, "FORM");
                if (i) {
                  var o = i.id || "",
                    a = e.id,
                    u = { f: i.action, c: "form:" + (i.name || o), cId: r };
                  return (
                    ("kw" != a && "search-kw" != a && "kw1" != a) ||
                      (u.w = e.value),
                    u
                  );
                }
              }
              return !1;
            },
            getBaseExtend: function () {
              return {};
            },
          },
          w = { trackUrl: null, clickUrl: null, areaIds: null, hbLogTimer: 0 },
          b = function (t) {
            return document.getElementById(t);
          };
        return {
          version: "v1.7.0 (2018.11.19)",
          util: m,
          data: v,
          config: w,
          sendLog: (function () {
            return (
              (n.__qihoo_monitor_imgs = {}),
              function (t) {
                var e = "log_" + +new Date(),
                  r = (n.__qihoo_monitor_imgs[e] = new Image());
                (r.onload = r.onerror =
                  function () {
                    n.__qihoo_monitor_imgs &&
                      n.__qihoo_monitor_imgs[e] &&
                      ((n.__qihoo_monitor_imgs[e] = null),
                      delete n.__qihoo_monitor_imgs[e]);
                  }),
                  (r.src = t);
              }
            );
          })(),
          buildLog: (function () {
            var t = "";
            return function (e, n) {
              if (!1 !== e) {
                e = e || {};
                var r = v.getBase(),
                  i = v.getBaseExtend(),
                  o = h.mix(r, i, !0);
                e = h.mix(o, e, !0);
                var a = n + h.encodeURIJson(e);
                if (a != t) {
                  (t = a),
                    setTimeout(function () {
                      t = "";
                    }, 100);
                  var u = h.encodeURIJson(e);
                  (u += "&t=" + +new Date()),
                    (n = n.indexOf("?") > -1 ? n + "&" + u : n + "?" + u),
                    this.sendLog(n);
                }
              }
            };
          })(),
          log: function (t, e) {
            e = e || "click";
            var n = w[e + "Url"];
            n || console.error("Error : the " + e + "url does not exist!"),
              this.buildLog(p.getExtend(e, t), n);
          },
          setConf: function (t, e) {
            var n = {};
            return (
              h.isObject(t) ? (n = t) : (n[t] = e),
              (this.config = h.mix(this.config, n, !0)),
              this
            );
          },
          setUrl: function (t) {
            return (
              t &&
                (this.util.getLocation = function () {
                  return t;
                }),
              this
            );
          },
          extendBase: function (t) {
            if (t && h.isObject(t)) {
              var e = h.mix(this.data.getBaseExtend(), t, !0);
              this.data.getBaseExtend = function () {
                return e;
              };
            }
            return this;
          },
          setProject: function (t, e) {
            return (
              t &&
                (this.util.getProject = function () {
                  return t;
                }),
              this.extendBase(e),
              this
            );
          },
          setId: function () {
            for (var t, e = [], n = 0; (t = arguments[n++]); )
              h.isArray(t) ? (e = e.concat(t)) : e.push(t);
            return this.setConf("areaIds", e), this;
          },
          init: function () {
            this.getClickAndKeydown(), this.getClickHeatmap(10, 1);
          },
          getTrack: function (t, e) {
            var n = this.data.getTrack(t);
            return (
              h.isObject(e) && (n = h.mix(n, e, !0)), this.log(n, "track"), this
            );
          },
          getClickHeatmap: function (t, e) {
            if (this.heatmapTimer) return this;
            this.heatmapTimer = !0;
            var n = this,
              r = [];
            (t = t || 10), (e = e || 5);
            var i = 0,
              a = function (o) {
                if ((clearTimeout(i), o || r.length > t)) {
                  if (!r.length) return;
                  return (
                    n.log(
                      { pos: r.join(","), sr: m.getScreenSize() },
                      "clickHeatMap"
                    ),
                    void (r = [])
                  );
                }
                i = setTimeout(function () {
                  a(!0);
                }, 60 * e * 1e3);
              };
            return (
              f.on(o, "mousedown", function (t) {
                var e = t.pageX + "." + t.pageY;
                r.push(e), a();
              }),
              this
            );
          },
          getClickAndKeydown: function () {
            var t = this;
            return (
              f.on(o, "mousedown", function (e) {
                var n = t.data.getClick(e);
                t.log(n, "click");
              }),
              f.on(o, "keydown", function (e) {
                var n = t.data.getKeydown(e);
                t.log(n, "click");
              }),
              (e.getClickAndKeydown = function () {
                return t;
              }),
              this
            );
          },
          beginHeartBeat: function (t, e, n) {
            var r = {};
            (r.id = t),
              h.isObject(e) && (r = h.mix(r, e, !1)),
              (n = isNaN(n) ? 10 : n),
              n > 60 ? (n = 60) : n < 5 && (n = 5);
            var i = this,
              o = function (t) {
                (r.steptime = t),
                  i.setConf("hbStarttime", Date.parse(new Date())),
                  i.log(r, "heartbeat"),
                  clearTimeout(w.hbLogTimer),
                  (w.hbLogTimer = setTimeout(function () {
                    var t = (Date.parse(new Date()) - w.hbStarttime) / 1e3;
                    o(t);
                  }, 1e3 * n));
              };
            return o(0), this;
          },
          endHeartBeat: function (t, e) {
            if ("undefined" != typeof w.hbStarttime && null !== w.hbStarttime) {
              var n = {};
              (n.id = t),
                h.isObject(e) && (n = h.mix(n, e, !1)),
                clearTimeout(w.hbLogTimer);
              var r = (Date.parse(new Date()) - w.hbStarttime) / 1e3;
              (n.steptime = r),
                this.log(n, "heartbeat"),
                this.setConf("hbStarttime", null);
            }
            return this;
          },
          setActiveTime: function (t) {
            return (m._activeTime = t), this;
          },
          addPlugin: function (t) {
            return p.addPlugin(t);
          },
        };
      })(window),
      n = "https:" === location.protocol.toLowerCase() ? "https:" : "http:";
    e
      .setConf({
        trackUrl: n + "//s.360.cn/qdas/s.htm",
        clickUrl: n + "//s.360.cn/qdas/c.htm",
        clickHeatMapUrl: n + "//s.360.cn/qdas/t.htm",
        wpoUrl: n + "//s.360.cn/qdas/p.htm",
        heartbeatUrl: n + "//s.360.cn/qdas/h.htm",
      })
      .init(),
      (window.QIHOO_MONITOR = e),
      "undefined" == typeof window.monitor && (window.monitor = e);
  }
})();
